#!/bin/bash
#
#  dashd The Dash Core server.
#
#
# chkconfig: 345 80 20
# description: dashd
# processname: dashd
#

# Source function library.
. /etc/init.d/functions

# you can override defaults in /etc/sysconfig/dashd, see below
if [ -f /etc/sysconfig/dashd ]; then
        . /etc/sysconfig/dashd
fi

RETVAL=0

prog=dashd
# you can override the lockfile via BITCOIND_LOCKFILE in /etc/sysconfig/dashd
lockfile=${BITCOIND_LOCKFILE-/var/lock/subsys/dashd}

# dashd defaults to /usr/bin/dashd, override with BITCOIND_BIN
dashd=${BITCOIND_BIN-/usr/bin/dashd}

# dashd opts default to -disablewallet, override with BITCOIND_OPTS
dashd_opts=${BITCOIND_OPTS--disablewallet}

start() {
    echo -n $"Starting $prog: "
    daemon $DAEMONOPTS $dashd $dashd_opts
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $lockfile
    return $RETVAL
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f $lockfile
    return $RETVAL
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status $prog
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo "Usage: service $prog {start|stop|status|restart}"
        exit 1
        ;;
esac
